<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>4.对象属性的声明</title>
</head>

<body>
  <script>
    class User {
      site = "后盾人";
      constructor(name) {
        this.name = name;
      }
      show () {
        console.log(`${this.site }:${this.name }`);
      }
      changeSite(value){
        this.site = value;
      }
    }
    let hd = new User("向军");
    hd.show();
    console.log(Object.getOwnPropertyNames(hd));// ['site', 'name']
    //修改属性
    hd.site = 'site2';
    console.log(hd.site);//site2
    hd.changeSite('site3');
    console.log(hd.site);//site3
  </script>
</body>

</html>